package comxin.demo3;

import comxin.Student;
import org.junit.Test;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Methoddemoe {
    @Test
    public void method1() throws Exception{
        Class<?> aClass = Class.forName("comxin.Student");
        Method[] methods = aClass.getMethods();
        for (Method method:methods){
            System.out.println(method);
        }
    }

    public void method2()throws Exception{
//        Class<?> aClass = Class.forName("comxin.Student");
        Method declaredMethod = this.getClass().getDeclaredMethod("show3", String.class);
//        Constructor<?> declaredConstructor = aClass.getDeclaredMethodConstructor();
//        Student student = (Student) declaredConstructor.newInstance();
//        System.out.println(o);
       declaredMethod.invoke(this,"张三");
    }
}
